function finance() {
	
	function SelectAll() {
		$("#mainbody .detail table th .chkbox").unbind("click");
		$("#mainbody .detail table th .chkbox").click(function() {
			var self = this;
			var tdchk = $("#mainbody .detail table td .chkbox");
			if (!self.checked) {
				tdchk.each(function() {
					var obj = this;
					this.checked = false;	
				});
			}
			else{
				tdchk.each(function() {
					var obj = this;
					this.checked = true;	
				});
			}
		});
	}
	
	function AdjustIfAllSelected() {
		$("#mainbody .detail table td").off("click", ".chkbox");
		$("#mainbody .detail table td").on("click", ".chkbox", function() {
			var self = this;
			var tdchk = $("#mainbody .detail table td .chkbox");
			var cktdchk = $("#mainbody .detail table td .chkbox:checked");
			var selectAll = $("#mainbody .detail table th .chkbox");
			if(cktdchk.length == tdchk.length) {
				selectAll[0].checked = true;
			}
			else{
				selectAll[0].checked = false;
			}
		});
	}
	
	$(function() {
		showDatePicker(".datepicker", "1950:2023", "images/date.gif");
		SelectAll();
		AdjustIfAllSelected();
	});
}
finance();


